package org.autumn.thread;

import java.util.concurrent.TimeUnit;

public class InterruptMethod2 {
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            while (true){
                if (Thread.currentThread().isInterrupted()){
                    System.out.println("interrupt ...");
                    break;
                }
            }
        }, "t1");

        t1.start();

        TimeUnit.SECONDS.sleep(1);
        // 外部线程打断t1  让t1线程停止
        t1.interrupt();
    }
}
